package com.capgemini.cn.authority.data.entity;

import com.capgemini.cn.authority.data.core.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 * <p>用户组成员表</p>
 * Created at 2017/8/21
 *
 * @author Andriy
 */
@Entity
@Table(name = "cg_group_members")
@NoArgsConstructor
@AllArgsConstructor
public class GroupMembers extends BaseEntity {

    /**
     * 用户名
     */
    @Column(name = "username", length = 50, nullable = false)
    @Getter
    @Setter
    private String userName;

    /**
     * 用户所在的组信息
     */
    @ManyToOne(targetEntity = Groups.class, optional = false, fetch = FetchType.LAZY)
    @JoinColumn(name = "group_id", referencedColumnName = "id", nullable = false, updatable = false)
    @Getter
    @Setter
    private Groups groups;
}
